#ifndef SOCKET_HPP
#define SOCKET_HPP

#include <cstdint>
#include <cstddef>

class Socket {
public:
    virtual ~Socket() = default;
    
    virtual bool bind(const char *address,uint16_t port) = 0;
    virtual bool listen(int max_conn) = 0;
    virtual Socket& accept() = 0;
    virtual bool connect(const char *address,uint16_t port) = 0;

    virtual size_t write(const void *buffer,size_t size) = 0;
    virtual size_t read(void *buffer,size_t size) = 0;

    virtual bool close() = 0;

    virtual bool setTimeout(uint32_t timeout_ms) = 0;
    virtual uint32_t getTimeout(void) const = 0;

    virtual int getErrorNumber(void) = 0;
public:
    static const uint32_t TIMEOUT_BLOCKING = 0x80000000;
};

#endif
